package de.sendorian.app.forumArchive.matcher;


import java.util.Arrays;
import java.util.Collection;

import org.apache.commons.lang.StringUtils;

import de.sendorian.app.forumArchive.domain.Topic;
import de.sendorian.util.matcher.BlacklistMatcher;

/**
 * Matches Topics by name as defined at construction time.
 *
 * @author sendorian
 *
 */
public class TopicNameMatcher extends BlacklistMatcher<Topic> {

	public TopicNameMatcher(String... matchingTopicNames) {
		super(Arrays.asList(matchingTopicNames));
	}

	public TopicNameMatcher(Collection<String> matchingTopicNames) {
		super(matchingTopicNames);
	}


	@Override
	protected boolean matchesInternal(Topic topic, Object unwantedTopic) {
		return StringUtils.equalsIgnoreCase(StringUtils.trim(topic.getName()), StringUtils
		    .trim((String) unwantedTopic));
	}

}
